package com.ruipengkj.commons.util;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;

import javax.swing.border.AbstractBorder;

public class ColorLineBorder extends AbstractBorder{

	private static final long serialVersionUID = 1L;
	
	private Color color = new Color(246, 163, 49);
	
	private Insets insets;
    public ColorLineBorder(Insets insets, Color color){
    	this.insets = insets;
    	this.color = color;
    }

    public void paintBorder(Component c, Graphics g, int x, int y,
                            int width, int height){
    	g.setColor(color);
    	if (insets.bottom != 0) {//底部
    		g.fillRect(0, c.getHeight()-insets.bottom, c.getWidth(), insets.bottom);
    	} 
    	if (insets.left != 0) {//左边
    		g.fillRect(0, 0, insets.left, c.getHeight());
    	} 
    	if (insets.top != 0) {//头部
    	} 
    	if (insets.right != 0) {//right
    		g.fillRect(c.getWidth()-insets.right, 0, insets.right, c.getHeight());
    	} 
    }
}
